// member
package form

import (
	"github.com/martini-contrib/binding"
	"martini_template/componnet"
	"net/http"
)

type MemberForm struct {
	Id       string `form:id`
	Username string `form:"username"`
	Password string `form:"password"`
	Nickname string `form:"nickname"`
	Realname string `form:"realname"`
	//Score int64 `form:score`
	//Balance float64 `form:balance`
	Sex      string `form:"sex"`
	Birthday string `form:"birthday"`
	Avatar   string `form:"avatar"`
	Email    string `form:"email"`
	Telphone string `form:"telphone"`
	IsActive string `form:"is_active"`
	HouseId string `form:"house_id"`
}

func (sf *MemberForm) Validate(errors binding.Errors, req *http.Request) binding.Errors {
	sf.Id = componnet.FilterString(sf.Id)
	sf.Username = componnet.FilterString(sf.Username)
	sf.Password = componnet.FilterString(sf.Password)
	sf.Nickname = componnet.FilterString(sf.Nickname)
	sf.Realname = componnet.FilterString(sf.Realname)
	sf.Sex = componnet.FilterString(sf.Sex)
	sf.Birthday = componnet.FilterString(sf.Birthday)
	sf.Avatar = componnet.FilterString(sf.Avatar)
	sf.Email = componnet.FilterString(sf.Email)
	sf.Telphone = componnet.FilterString(sf.Telphone)
	sf.IsActive = componnet.FilterString(sf.IsActive)
	return errors
}
